import torch
from transformers import BertTokenizer, BertModel

def calculate_similarity(original_text, summary_text):
    tokenizer = BertTokenizer.from_pretrained('bert-base-chinese')
    model = BertModel.from_pretrained('bert-base-chinese')
    
    def get_embeddings(text):
        tokens = tokenizer(text, return_tensors='pt', truncation=True, padding=True)
        with torch.no_grad():
            output = model(**tokens)
        return output.last_hidden_state.mean(dim=1)
    
    original_embedding = get_embeddings(original_text)
    summary_embedding = get_embeddings(summary_text)
    cosine_similarity = torch.nn.functional.cosine_similarity(original_embedding, summary_embedding)
    return cosine_similarity.item()
